<script type="text/javascript">
  function close_me(){
    $("#add_sentence").hide();
  }
  function  add_sentence(){
    $("#add_sentence").show();
    $("#no_content").hide();
  }
  
  $().ready(function() {
    $("#new_sentence_form").validate({
      rules: { "sentence[content]": {
          required: true
        },"sentence[translation]": {
          required: true
        }
      },
      messages:{
        "sentence[content]": {
          required: "例句不能为空."
        },"sentence[translation]": {
          required: "译文不能为空."
        }
      }
    })
  });
</script>
<div class="sub_pannel">
  <div class="content">
    <div class="title">
      <span class="text">
        单词卡片
      </span><%= link_to '编辑该单词' ,edit_item_path(@item,:course_id=>@item.course_id) %>
    </div>
    <div class="show_item_pannel">
      <p style="margin-bottom:30px;">
        <span class="item_label">单词</span>
        <span class="item_body"><%= @item.kanji %></span>「<span class="item_body"><%= @item.kana %></span>」
      </p>
      <p>
        <span class="item_label">词性</span>
        <span><%= @item.pos %></span>
      </p>
      <p>
        <span class="item_label">翻译</span>
        <span><%= @item.translation %></span>
      </p>
    </div>
  </div>
</div>
<div class="sub_pannel">
  <div class="content">
    <span class="add_button"><%=link_to_function '添加例句', 'add_sentence();'%></span>
    <div class="title">
      <span class="text">【<%= @item.kanji %>】的例句</span>
    </div>
    <div id="sentences">
      <%unless @sentences.empty?%>
        <%= render :partial=>'sentences/item', :collection=>@sentences%>
      <%else%>
        <div id="no_content">没有例句.请点击有右侧链接 添加例句.</div>
      <%end%>
    </div>
    <div id="add_sentence" style="display:none;">
      <span class="close_x"><%= link_to_function "x", 'close_me()' %></span>
      <%remote_form_for Sentence.new,new_sentence_path ,:html=>{:id=>"new_sentence_form"} do  |f|%>
        <p>
          <%=label_tag "例句",nil, :class=>'label'%>
          <%= f.text_field "content" ,:class=>'text'%><span></span>
        </p>
        <p>
          <%=label_tag "例句译文", nil, :class=>'label'%>
          <%= f.text_field  "translation",:class=>'text'%><span></span>
        </p>
        <p class="p_submit">
          <%= hidden_field_tag "sentence[item_id]",@item.id%>
          <%=submit_tag "添加例句" ,:class=>'submit'%>
        </p>
      <%end%>
    </div>
  </div>
</div>
